<template>
  <div class="page-department">
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>项目部信息
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <div class="component-searchHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">
            <span class="iconfont">&#xe63d;</span> 筛选查询
          </p>
          <div class="right">
            <button @click="searchInfo()">查询</button>
          </div>
        </div>
      </div>
    </div>
    <div class="component-search-box">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="输入搜索：">
          <el-input v-model="formInline.info" placeholder="项目部名称" clearable></el-input>
        </el-form-item>
        <!-- <el-form-item label="所属区域：">
          <el-select v-model="formInline.area" placeholder="全部" clearable>
            <el-option
              v-for="item in options"
              :key="item.label"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="所属区域：" placeholder="全部" clearable>
              <el-cascader
                :options="options"
                v-model="formInline.area"
                @change="handleChange"
                style="width:326px;"
                class="wd400"
                clearable>
              </el-cascader>
            </el-form-item>
      </el-form>
    </div>
    <div class="component-listHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">
            <span class="iconfont">&#xe61e;</span>
            {{title}}
          </p>
          <p class="right-text" @click="$router.push({name:'addProject'})">
            添加项目部
          </p>
        </div>
      </div>
    </div>

    <div class="table">
      <el-table
        ref="multipleTable"
        :data="info"
        tooltip-effect="dark"
        style="width:100%"
        border>
        <el-table-column label="编号" align="center" width="150" prop="orgNumber"></el-table-column>
        <el-table-column label="项目部名称" align="center" width="230" prop="orgName"></el-table-column>
        <el-table-column label="项目负责区域" align="center" width="230" prop="district"></el-table-column>
        <el-table-column label="区域负责人" align="center" width="230" prop="leaderName"></el-table-column>
        <el-table-column label="操作信息" align="center">
          <template slot-scope="scope">
            <a class="options" @click.prevent="edit(scope.row)">编辑</a>
            <a class="options" @click.prevent="deleteOrg(scope.row.orgId)">删除</a>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页 -->
    <div class="component-paging" v-if="info.length > 0">
      <div class="table-bottom">
        <div class="bottom-left" style="margin-left: 42px;">
        </div>
        <div class="paging">
          <div class="paging-left">
            <p>
              共
              <span>{{Math.ceil(total/pageSize)}}</span> 页/
              <span>{{total}}</span> 条数据
            </p>
          </div>
          <el-pagination
            background
            @size-change="SizeChange($event,orgInit,currentPage,pageSize)"
            @current-change="CurrentChange($event,orgInit,currentPage,pageSize)"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30]"
            :page-size="pageSize"
            layout="sizes, prev, pager, next, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
    </div>

    <!--终止派单弹框-->
    <!--<div class="component-model">-->
      <!--<el-dialog title="终止派单" :visible.sync="dialogVisible" width="600px">-->
        <!--<div class="copy">-->
          <!--备注信息：<el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="textarea">-->
        <!--</el-input>-->
        <!--</div>-->
        <!--<span slot="footer" class="dialog-footer">-->
          <!--<el-button @click="dialogVisible = false">取消</el-button>-->
          <!--<el-button @click="dialogVisible = false;">确定</el-button>-->
        <!--</span>-->
      <!--</el-dialog>-->
    <!--</div>-->

  </div>
</template>

<script>
import area from '@/assets/js/area.js'
  export default {
    name: "operation",
    data() {
      return {
        title: "项目部信息",
        outputList: true,
        info: [],
        formInline:{
          info:'',
          area: ["", "",""]
        },
        //条件查询
        options: [],
        value: '',
        // 数据总条数
        total: 0,
        // 每页显示数据的条数
        pageSize: 10,
        // 当前显示的页面页码
        currentPage: 1,
        multipleSelection:[],//全选
//        dialogVisible:false,//弹框是否显示
        textarea:'', //备注信息
        checkList:[],//选中列表
        options:area, //省市区
      };
    },
    created(){
      this.orgInit()
    },

    mounted(){

    },
    methods: {
      // 查询按钮
      searchInfo(){
        this.currentPage = 1;
        this.orgInit()
      },
      orgInit(){
        let that = this,
        suCb = res => {
          console.log(res);
          that.info = that.deepClone(res.data.data);
          that.total = res.data.rowCount
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proProject/selectOrgPro",
          methods: "post",
          data: { 
            info:that.formInline.info,
            name:that.formInline.area,
            pageSize:that.pageSize,
            pageCurrent:that.currentPage
           },
          success: suCb,
          error: erCb
        };
        console.log("查询参数：")
        console.log(req.data)
      that.$https(req);
      },
      //删除
      deleteOrg(id){
        this.$confirm('确认删除吗？')
        .then(_ => {
          let that = this,
        suCb = res => {
          that.$msg('删除成功！')
          that.orgInit()
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/sysOrg/deleteOrgPro",
          methods: "post",
          data: { 
            orgId:id
           },
          success: suCb,
          error: erCb
        };
      that.$https(req);
        })
        .catch(_ => {});
      },
      edit(val){
        this.$router.push({
          name: 'addProject',
          params: {
            info:val,
            flag:1
          }
        })
      },

      handleDelete(){

      },
      getArea(value, selectedData) {
        const areaName = selectedData.map(item => item.label)
        this.args = [...areaName]
        console.log(this.value2)
      },
      handleChange(){
        console.log(this.formInline.area)
      }
    },
  };
</script>

<style scoped>
  .component-searchHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
  }

  .component-searchHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-searchHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    line-height: 45px;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    text-align: left;
    margin: 0 0 0 30px;
  }
  .right-text{
    height: 30px;
    line-height: 30px;
    margin-top: 7px;
    margin-right: 20px;
    font-size: 14px;
    color: #fff;
    padding: 0 10px;
    border-radius: 4px;
    background: #1ABC9C;
    cursor: pointer;
  }

  .component-searchHeader .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 30px;
  }

  .component-searchHeader .right button {
    padding: 0 15px;
    height: 30px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 12px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-searchHeader .right button:hover {
    background-color: #f3f3f3;
  }

  .component-search-box {
    width: 1100px;
    height: 60px;
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #e4e4e4;
    border-top: none;
    margin: 0 auto;
    text-align: left;
    padding-left: 30px;
    line-height: 60px;
  }

  .component-search-box .el-input__inner {
    height: 36px;
    display: inline-block;
    vertical-align: middle;
  }

  .component-listHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
    border-bottom: 0;
  }

  .component-listHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-listHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    line-height: 45px;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-listHeader .search-header .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 10px;
  }

  .component-listHeader .search-header .right button {
    padding: 0 15px;
    height: 30px;
    width: 80px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 14px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-listHeader .search-header .right button:hover {
    background-color: #f3f3f3;
  }

  .component-listHeader .search-header .right .right-select-margin {
    margin-top: 6px;
    margin-right: 8px;
  }

  .component-table-header {
    width: 1100px;
    margin: 0 auto;
    display: flex;
    border: 1px solid #e4e4e4;
    background-color: #f9fafc;
    height: 45px;
    line-height: 45px;
    padding: 0;
    list-style: none;
    justify-content: space-between;
    box-sizing: border-box;
    border-top: none;
  }

  .component-table-header li:first-child {
    width: 50px;
  }

  .component-table-header li:first-child span {
    border-radius: 5px;
    border: 2px solid #aba2a2;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin: 12.5px auto;
    line-height: 16px;
    font-size: 16px;
  }

  .component-table-header li {
    border-right: 1px solid #e4e4e4;
    font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
    font-weight: 650;
    font-style: normal;
    font-size: 14px;
    color: #666666;
  }
  .component-table-header li:last-child {
    border: none;
  }

  .component-table-body {
    width: 1100px;
    margin: 0 auto;
    display: flex;
    border: 1px solid #e4e4e4;
    background-color: #fff;
    height: 45px;
    line-height: 45px;
    padding: 0;
    list-style: none;
    justify-content: space-between;
    box-sizing: border-box;
    border-top: none;
  }

  .component-table-body li {
    font-size: 12px;
    color: #666;
    text-align: center;
    border-right: 1px solid #e4e4e4;
  }

  .component-table-body li:first-child {
    width: 50px;
  }

  .component-table-body li:nth-child(2) {
    width: 100px;
  }

  .component-table-body li:nth-child(3) {
    width: 150px;
  }

  .component-table-body li:nth-child(4) {
    width: 150px;
  }
  .component-table-body li:nth-child(5) {
    width: 150px;
  }

  .component-table-body li:last-child {
    width: 500px;
    border-right: none;
  }

  .component-table-body li:last-child {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    padding: 0 auto;
  }

  .component-table-body li:last-child a {
    display: inline-block;
    text-align: center;
    color: #1abc9c;
    text-decoration: none;
    font-size: 12px;
  }

  /* 下面都是修改饿了么ui的下拉框和按钮选中后的样式 */

  .el-select .el-input.is-focus .el-input__inner,
  .el-select .el-input__inner:focus {
    border-color: #e4e4e4;
  }

  .el-select-dropdown__item.selected {
    color: #666;
    font-weight: 400;
  }

  .el-select-dropdown {
    min-width: 100px !important;
    top: 50px !important;
    margin-left: 5px;
  }
  .el-select-dropdown__item {
    height: 26px;
    line-height: 26px;
  }

  .el-select .el-input__inner {
    width: 100px;
    padding: 0 8px;
    margin: 6px 5px;
  }
  .component-paging .table-bottom .all-left button {
    background-color: #fff;
  }
  .component-paging .table-bottom .all-left button:hover {
    background-color: #f3f3f3;
  }

  .table {
    width: 1100px;
    margin: 0 auto;
  }
  .options{
    color: #1ABC9C;
    padding: 0 5px;
    cursor: pointer;
  }
  .el-textarea{
    width: 220px;
    vertical-align: top;
  }
</style>
